package testcase;

import junit.framework.TestCase;
import roster.Schedule;
import roster.ScheduleModifier;

public class TestScheduleModifier extends TestCase{
	public static Schedule testObj;
	public int noOfRecords=5;
	public String name="testObj";
	public int date=19022013;
	public String[] staffName={"Eva", "Coach", "Yanis", "Peter", "Marry"};
	public String[][] time={{"ABC", "BC", "AC", "B", "C", "-", "-"},
							{"ABC", "BC", "AC", "B", "C", "-", "-"},
							{"ABC", "BC", "AC", "B", "C", "-", "-"},
							{"ABC", "BC", "AC", "B", "C", "-", "-"},
							{"ABC", "BC", "-", "-", "-", "-", "-"}};
	
	public void testQuery(){
		testObj=new Schedule(noOfRecords,name,date,staffName,time);
		//test false command
		boolean quearyStat=ScheduleModifier.query(testObj, "change");
		assertEquals(quearyStat,false);
		quearyStat=ScheduleModifier.query(testObj, "change dfg");
		assertEquals(quearyStat,false);
		quearyStat=ScheduleModifier.query(testObj, "change date date");
		assertEquals(quearyStat,false);
		quearyStat=ScheduleModifier.query(testObj, "change date1 date");
		assertEquals(quearyStat,false);
		quearyStat=ScheduleModifier.query(testObj, "change date1 date sadf");
		assertEquals(quearyStat,false);
		quearyStat=ScheduleModifier.query(testObj, "iuhi dfg 123 sdfsdf sfdsf");
		assertEquals(quearyStat,false);
		quearyStat=ScheduleModifier.query(testObj, "change 0 5 sd");
		assertEquals(quearyStat,false);
		quearyStat=ScheduleModifier.query(testObj, "change 6 5 sd");
		assertEquals(quearyStat,false);
		quearyStat=ScheduleModifier.query(testObj, "change 1 0 sd");
		assertEquals(quearyStat,false);
		quearyStat=ScheduleModifier.query(testObj, "change 1 8 sd");
		assertEquals(quearyStat,false);
		quearyStat=ScheduleModifier.query(testObj, "add");
		assertEquals(quearyStat,false);
		quearyStat=ScheduleModifier.query(testObj, "add 0 -");
		assertEquals(quearyStat,false);
		quearyStat=ScheduleModifier.query(testObj, "add 0 0 sd");
		assertEquals(quearyStat,false);
		quearyStat=ScheduleModifier.query(testObj, "delete 6");
		assertEquals(quearyStat,false);
		quearyStat=ScheduleModifier.query(testObj, "delete 0");
		assertEquals(quearyStat,false);
		quearyStat=ScheduleModifier.query(testObj, "delete A");
		assertEquals(quearyStat,false);
		quearyStat=ScheduleModifier.query(testObj, "delete A sdf");
		assertEquals(quearyStat,false);
		testObj=ScheduleModifier.getResult();
		testObj.toString();
		//test correct change date command
		quearyStat=ScheduleModifier.query(testObj, "change date 11112011");
		assertEquals(quearyStat,true);
		testObj=ScheduleModifier.getResult();
		assertEquals(testObj.getStartDate(),11112011);
		//test correct change time command
		quearyStat=ScheduleModifier.query(testObj, "change 1 1 CCC");
		assertEquals(quearyStat,true);
		testObj=ScheduleModifier.getResult();
		assertEquals(testObj.getTime()[1-1][1-1],"CCC");
		quearyStat=ScheduleModifier.query(testObj, "change 5 7 BBB");
		assertEquals(quearyStat,true);
		testObj=ScheduleModifier.getResult();
		assertEquals(testObj.getTime()[5-1][7-1],"BBB");
		//no staff
		testObj=new Schedule("sfsdsf",1234586); //*****************************null object now
		quearyStat=ScheduleModifier.query(testObj, "change 1 1 CCC");
		assertEquals(quearyStat,false);
		//test correct add staff command
		quearyStat=ScheduleModifier.query(testObj, "add IamNew");
		assertEquals(quearyStat,true);
		testObj=ScheduleModifier.getResult();
		assertEquals(testObj.getStaffName()[0],"IamNew");
		assertEquals(testObj.getNoOfRecords(),1);
		//test correct delete staff command
		quearyStat=ScheduleModifier.query(testObj, "delete 1");
		assertEquals(quearyStat,true);
	}
}
